package xddq

import (
	"context"
	"fmt"
	"io/ioutil"
	"net/http"
	"strings"
	"websocket_apn/log"
	http_transport "websocket_apn/transfer/net/http"
)

func ForumSignIn() error {
	head := http.Header{}
	data := "play_platform=web&app_version=1.0.0&from_type=2&task_type=1&fid=201&pid=&source_t=wxxyx"
	url := "https://luntan.oiz611.com/api/mobile/index.php?module=gamebox&func=do_exp_task&version=4&mapifrom=wx&charset=utf-8&game_id=913&pf=1&video=1&forbid_share=1&loginout=0&sid=3109673&role_id=3109673861602&user_token=MmE5OVZjRXY4cXhpTE0rOERYd0llU0xrZjhGb1p4SGdRMnFYN3JneUVuZWN1UHU4SzBWdTQyQ3psRno2NkE4Qm1ycExXKzdFYXVIY0RlRzRHQ0M4cXJFK2g5UVJ3cDRXSVlrNEl6VWtIMjl5VXNvY2s4U3IwdDdCYjFkdkxrUy9EcUlVZVMzNlJNaDlKL0pmZnN0bTRHNC83eG5YY0VmV3VvY0lvOUY1L0VkRjBBUThIcy9XQmlzbHZBQmpzeE5xNWJsRStheG9xL3dUZ1FkSCsyR0xMSndvM25QTXR4SXNibDRKRWU3c09MR1dUQ01kSkEw"
	method := "POST"
	head.Add("Host", "luntan.oiz611.com")
	head.Add("Connection", "keep-alive")
	head.Add("Accept", "application/json, text/plain, */*")
	head.Add("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36 MicroMessenger/7.0.20.1781(0x6700143B) NetType/WIFI MiniProgramEnv/Windows WindowsWechat/WMPF WindowsWechat(0x63090a13) XWEB/9129")
	head.Add("Content-Type", "application/x-www-form-urlencoded")
	head.Add("Origin", "https://luntan.oiz611.com")
	head.Add("Sec-Fetch-Site", "same-origin")
	head.Add("Sec-Fetch-Mode", "cors")
	head.Add("Sec-Fetch-Dest", "empty")
	head.Add("Referer", "https://luntan.oiz611.com/new_m/")
	head.Add("Accept-Encoding", "gzip, deflate, br")
	head.Add("Accept-Language", "zh-CN,zh;q=0.9")
	c, _ := http_transport.NewClient()
	ctx := context.WithValue(context.Background(), "url", url)
	ctx = context.WithValue(ctx, "method", method)
	ctx = context.WithValue(ctx, "Header", head)
	payload := strings.NewReader(string(data))
	resp, err := c.RoundTrip(ctx, payload)
	if err != nil {
		return fmt.Errorf("Forum SignIn error: %s\n", err.Error())
	}
	defer resp.Body.Close()
	all, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		return fmt.Errorf("Forum SignIn read body error: %s\n", err.Error())
	}
	log.Debugf("%s\n", all)
	return nil
}

/*
https://commonwechat.37.com/?c=miniprogram-dqghd&a=getMiniWxToken
code=0d324Cml2goyqd4Kw6ll2ib7l7124CmZ

https://activity.37.com/dist/xddq/flzx/indexm.html?sdk=2&game_id=900&forbid_share=1&from_type=miniProgram&mini_sign=iBjSV2lEKIdxFCOwZDsDfxqnATdrzwPxiXA0kC81D12qlVMjWCpaRrZqbUu80uioqw9daqnCPRIChsQ8rTDv2XiO%2FCZ2VrTuwCKiVg&mini_app_pst=iBjSV2lEKIdxFCDhN2oIexqjBDJmwgOghnUVqS4HJW%2FmhEAbIRZpeZkRZiuKxYmqoxZkV%2FXqInh%2BzJdV2mC%2B0BqwmyAKVtnmhVPxKGQIz3GV5iLsMQumVPIHVJQbHn%2BQHe4uwhHG45dR5hlYbPA6%2F%2Fm92dbA3toiw7rWUTR8sdX1FIiz%2FJ4H04yLBcGJzKeXzVzL1OLetPRZLePz3X7UBpNGLBrlrlcgidqX9jaLfn51VmOV23M1BJP%2Fi%2B9GUcfio3Wd6pQm94BqAREhQN5nB43B7nuuI5fErv4SX%2FNOLs%2B1GVW3DhVw5zs3m9zoI7RyFeZF7LlERzDRmAIlQvrlyQdhVCr%2FMB7YhbIlPByl9Nd2JFYIsQc%2FI96FnBPWUO9uBQ6w1U52Udbyx4h7guOHu0pI3pG2JsQ0DEo%2FCymGcMBMp0X6hEuR4nFJfB2X%2BR2%2Bg2c&sid=3109673&role_id=3109673861602
https://activity.37.com/dist/xddq/flzx/indexm.html?sdk=2&game_id=900&forbid_share=1&from_type=miniProgram&mini_sign=iBjSV2lEKIdxFHDrYjsHeRqnAmZmmQH0iyY0kC81D12qlVMjWCpaRrZqbUu80uioqw9daqnCPRIChsQ8rTDv2XiO%2FCZ2VrTuwyehXg&mini_app_pst=iBjSV2lEKIdxFHjmbjlSeUykA2Awzlan3CEVhAgCJWyvwlglJRlQZIJvZBWzoZKEpyFgW8%2FNFmdh7Lt32jmXtAa0n38RKtSAgUzxOW9Cykq01CGlMRqlU9RbY5daO0%2FOP5ItnQn55ZVr6yJaa4g8idzj7unHr8Ej%2FcDkQTxmrtXpBb6xnPkw0YiMAevy%2BKiGojr7opizncBeK%2FqE4Bv8BsJOOxvQ4W9Vo9mv2yqHfB0XDmLt%2FWstXKm%2Bi8B7UMbEs3uwtJxZ8JxHbBIPfZFXLu7K60aIKYzErdwMOud9GruLEGLtKDhn9Fs5t%2BTkXpw4ctx0pJADd2vBjBsmStngrwtXZ1zGASf9pJASS2u59%2Fx2EnobiAY8NPDamnTKU9tqBS2diVJ0WrLcj755q62Pu29pw86uH%2FYYDzoObRCHc9FXmXHHsg%2Bm40RrSiWx7hyhtXc&sid=3109673&role_id=3109673861602&timestamp=1714996251001

*/
